/*******************************************************************************
* File Name: Thermistor.h
* Version 1.20
*
* Description:
*  This header file provides registers and constants associated with the
*  ThermistorCalc component.
*
* Note:
*  None.
*
********************************************************************************
* Copyright 2013, Cypress Semiconductor Corporation.  All rights reserved.
* You may use this file only in accordance with the license, terms, conditions,
* disclaimers, and limitations in the end user license agreement accompanying
* the software package with which this file was provided.
*******************************************************************************/

#if !defined(CY_THERMISTOR_CALC_Thermistor_H)
#define CY_THERMISTOR_CALC_Thermistor_H

// #include "cyfitter.h"
// #include "CyLib.h"
#include "user_global.h"

#define Thermistor_EQUATION_METHOD        (0u) /* 方程法 */
#define Thermistor_LUT_METHOD             (1u) /* 查表法 */

#define Thermistor_IMPLEMENTATION         Thermistor_EQUATION_METHOD

#if (Thermistor_IMPLEMENTATION == Thermistor_EQUATION_METHOD)
    #include <math.h>
#endif /* (Thermistor_IMPLEMENTATION == Thermistor_EQUATION_METHOD) */

/* Porting redefinition */
typedef unsigned long int uint32;
typedef signed long int int32;
typedef unsigned short uint16;
typedef signed short int16;
// typedef float float32;
typedef double float32;
typedef double float64;


/***************************************
*   Conditional Compilation Parameters
***************************************/

/* B57861S0103: 0℃ ~ +50℃ */
#define Thermistor_0_50_B57861S0103_REF_RESISTOR           (10000) /* Ω */
#define Thermistor_0_50_B57861S0103_REF_RES_SHIFT          (0u)
#define Thermistor_0_50_B57861S0103_ACCURACY               (10u)
#define Thermistor_0_50_B57861S0103_MIN_TEMP               (0 * Thermistor_0_50_B57861S0103_SCALE) /* 0.00℃ ~ +50.00℃ */

/* NCP18XH103F03RB: 10K: -30℃ ~ +110℃ */
#define Thermistor_n30_110_10K_REF_RESISTOR           (10000) /* Ω */
#define Thermistor_n30_110_10K_REF_RES_SHIFT          (0u)
#define Thermistor_n30_110_10K_ACCURACY               (10u)
#define Thermistor_n30_110_10K_MIN_TEMP               (-30 * Thermistor_n30_110_10K_SCALE) /* -30.00℃ ~ +110.00℃ */


#define Thermistor_REF_RESISTOR           Thermistor_0_50_B57861S0103_REF_RESISTOR
#define Thermistor_REF_RES_SHIFT          Thermistor_0_50_B57861S0103_REF_RES_SHIFT
#define Thermistor_ACCURACY               Thermistor_0_50_B57861S0103_ACCURACY
#define Thermistor_MIN_TEMP               Thermistor_0_50_B57861S0103_MIN_TEMP


/***************************************
*        Function Prototypes
***************************************/

uint32 Thermistor_GetResistance_2(int16 vReference, int16 vThermistor);
uint32 Thermistor_GetResistance_1(int16 vReference, int16 vThermistor);
int16 Thermistor_GetTemperature(uint32 resT);


/***************************************
*           API Constants
***************************************/

/* B57861S0103: 0℃ ~ +50℃ */
#define Thermistor_0_50_B57861S0103_SCALE             (100)
#define Thermistor_0_50_B57861S0103_LUT_SIZE          (501u)

#define Thermistor_0_50_B57861S0103_THA               (0.001125257)
#define Thermistor_0_50_B57861S0103_THB               (0.0002347204)
#define Thermistor_0_50_B57861S0103_THC               (8.563052E-08)

/* NCP18XH103F03RB: -30℃ ~ +110℃ */
#define Thermistor_n30_110_10K_SCALE                  (100)
#define Thermistor_n30_110_10K_LUT_SIZE               (1401u)


#define Thermistor_K2C                    (273.15)
#define Thermistor_SCALE                  Thermistor_0_50_B57861S0103_SCALE
#if (Thermistor_IMPLEMENTATION == Thermistor_EQUATION_METHOD)
    #define Thermistor_THA                   Thermistor_0_50_B57861S0103_THA
    #define Thermistor_THB                   Thermistor_0_50_B57861S0103_THB
    #define Thermistor_THC                   Thermistor_0_50_B57861S0103_THC
#else /* Thermistor_IMPLEMENTATION == Thermistor_LUT_METHOD */
    #define Thermistor_LUT_SIZE              Thermistor_0_50_B57861S0103_LUT_SIZE
#endif

#endif /* CY_THERMISTOR_CALC_Thermistor_H */


/* [] END OF FILE */
